package springstudy.web.servlet;

import javax.servlet.FilterChain;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebFilter;
import javax.servlet.http.HttpFilter;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import java.io.IOException;

/**
 * 这里需要继承HttpFilter是Servlet3.0的规范
 * 默认的是不支持异步操作的，需要开启
 */
@WebFilter(urlPatterns = "/my/servlet",asyncSupported = true)
public class MyFilter extends HttpFilter {

	@Override
	protected void doFilter(HttpServletRequest request, HttpServletResponse response, FilterChain chain) throws IOException, ServletException {
		System.out.println("自定义的servlet filter");
		super.doFilter(request,response,chain);
	}
}
